package algotithm.leetcode.twopoint.test162;

/**
 * @author zhouyanxiang
 * @Date 2021-02-2021/2/2-14:57
 * @Title 162 寻找峰值
 */
public class Solution {

    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] nums = {1,2,3,1};
        int n = solution.findPeakElement(nums);
        System.out.println(n);
    }

    public int findPeakElement(int[] nums) {
        for (int i = 0; i < nums.length - 1; i++) {
            if (nums[i] > nums[i+1]) {
                return i;
            }
        }
//        for (int i = 1; i < nums.length - 1; i++) {
//            if (nums[i] > nums[i-1] && nums[i] > nums[i+1]) {
//                return i;
//            }
//        }
        return nums.length - 1;
    }
}
